package com.youku.utils
{
   import com.youku.interfaces.IPlayListData;
   import com.youku.core.model.vo.VideoSegmentData;
   import com.youku.core.CoreContext;
   import com.youku.constants.IKuActions;
   import com.youku.P2PConfig;
   import com.youku.data.PlayerConstant;
   import com.youku.PlayerConfig;
   
   public class GetUrl extends Object
   {
      
      public function GetUrl() {
         super();
      }
      
      public static function getFileParameters(param1:int, param2:IPlayListData, param3:VideoSegmentData, param4:Boolean, param5:int = 0) : String {
         var _loc11_:String = null;
         var _loc6_:* = "";
         var _loc7_:String = param1.toString(16);
         if(_loc7_.length == 1)
         {
            _loc7_ = "0" + _loc7_;
         }
         _loc6_ = _loc6_ + ("/sid/" + param2.sid + "_" + _loc7_);
         var _loc8_:String = param2.fileType;
         if(param2.fileType == "hd2" || param2.fileType == "hd3")
         {
            _loc8_ = "flv";
         }
         if(param2.drm)
         {
            _loc8_ = "f4v";
         }
         _loc6_ = _loc6_ + ("/st/" + _loc8_);
         _loc6_ = _loc6_ + ("/fileid/" + param3.fileId);
         if(param4)
         {
            if(param2.drm)
            {
               _loc6_ = _loc6_ + "?K=";
            }
            else
            {
               _loc6_ = _loc6_ + ("?start=" + int(param5) + "&K=");
            }
         }
         else
         {
            _loc6_ = _loc6_ + "?K=";
         }
         if(param3.key == "")
         {
            _loc6_ = _loc6_ + (param2.key2 + param2.key1);
         }
         else
         {
            _loc6_ = _loc6_ + param3.key;
         }
         if(param2.fileType == "flv" || param2.fileType == "flvhd")
         {
            _loc6_ = _loc6_ + "&hd=0";
         }
         else if(param2.fileType == "mp4")
         {
            _loc6_ = _loc6_ + "&hd=1";
         }
         else if(param2.fileType == "hd2")
         {
            _loc6_ = _loc6_ + "&hd=2";
         }
         else if(param2.fileType == "hd3")
         {
            _loc6_ = _loc6_ + "&hd=3";
         }
         
         
         
         var _loc9_:String = CoreContext.playerProxy.playerData.getIkuState(IKuActions.LOAD);
         _loc9_ = _loc9_ == ""?"0":_loc9_;
         _loc6_ = _loc6_ + ("&myp=" + _loc9_);
         _loc6_ = _loc6_ + ("&ts=" + int(param3.seconds));
         if(param2.show)
         {
            if(param2.show.isVideoPaid == 1)
            {
               _loc6_ = _loc6_ + "&ypremium=1";
            }
            else
            {
               _loc6_ = _loc6_ + "&ymovie=1";
            }
         }
         _loc6_ = _loc6_ + ("&ypp=" + P2PConfig.ypp);
         _loc6_ = _loc6_ + ("&ctype=" + PlayerConstant.CTYPE);
         _loc6_ = _loc6_ + ("&ev=" + PlayerConstant.EV);
         _loc6_ = _loc6_ + ("&token=" + param2.tk);
         _loc6_ = _loc6_ + ("&oip=" + param2.oip);
         var _loc10_:String = param2.sid + "_" + param3.fileId + "_" + param2.tk;
         _loc10_ = _loc10_ + ("_" + PlayerConfig.bctime);
         _loc11_ = PlayListUtil.getInstance().changeSize(_loc10_);
         _loc6_ = _loc6_ + ("&ep=" + PlayListUtil.getInstance().setSize(_loc10_ + "_" + _loc11_.substr(0,4)));
         return _loc6_;
      }
   }
}
